﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SIMS_GUI_Item
{
    public partial class PersonalInformation : Form
    {
        public PersonalInformation()
        {
            InitializeComponent();
        }

        public PersonalInformation(string UserName)
        {
            InitializeComponent();
            this.lbl_UserName.Text = UserName;
        }

        SqlConnection conn = new SqlConnection(@"Data Source=DESKTOP-3CMC9MB\SQLEXPRESS;Initial Catalog=SIMS GUI Item DataBase;Integrated Security=True;");
        private void PersonalInformation_Load(object sender, EventArgs e)
        {
            string UserName = this.lbl_UserName.Text;
            var sql =string.Format(@"select RealName,Sex,UserName,IdentityCard from UserInformation where UserName='{0}'",UserName);
            SqlCommand comm = new SqlCommand(sql, conn);
            DataSet ds = new DataSet();
            SqlDataAdapter adp = new SqlDataAdapter(sql, conn);
            adp.Fill(ds);
            this.dgv_PersonalInformation.DataSource = ds.Tables[0];
            //是否允许自动创建列
            this.dgv_PersonalInformation.AutoGenerateColumns = false;
            //不允许出现空行
            this.dgv_PersonalInformation.AllowUserToAddRows = false;
            //整行选中
            this.dgv_PersonalInformation.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            //是否允许多选
            this.dgv_PersonalInformation.MultiSelect = false;
            this.dgv_PersonalInformation.RowTemplate.Height = 50;
        }
    }
}
